# controller
# responsible for program execution
# refers to the different available pages

# declare explicit which django-version should be used
#import os
#os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
#
#from google.appengine.dist import use_library
#use_library('django', '1.2')
#use_library('django', '0.96')

# other necessary imports
from google.appengine.ext.webapp.util import run_wsgi_app
from google.appengine.ext import webapp
from google.appengine.api import users

from model.octopus.credentials.SetCredentials import *
from model.octopus.credentials.DeleteCredentials import *
from model.octopus.credentials.DeleteAllCredentials import *

from model.octopus.datastore.OctopusCloudDatabase import *
from model.octopus.login.MainPage import *
from model.octopus.regions.SetRegions import *
from model.octopus.i18n.Language import *
from model.octopus.synchronize.SynchronizeStorages import *
from model.octopus.cache.LocalCaching import *

from model.octopus.raid.RaidLevelConfig import * 
from model.octopus.raid.RaidOneInfo import *
from model.octopus.raid.RaidFiveInfo import *
from model.octopus.raid.MergeFile import *

from model.storages.acl.ViewACL import *
from model.storages.acl.ChangeACL import *
from model.storages.keys.DeleteBucketKey import *
from model.storages.keys.DeleteAllBucketKeys import *
from model.storages.s3.SelectData import *
from model.storages.s3.FileUploadHandler import *

from controller.BuildDeleteAllKeysQuestion import *
from controller.BuildStorageInfo import *
from controller.BuildChooseRaidLevel import *

import wsgiref.handlers


def main():
    application = webapp.WSGIApplication([('/', MainPage),
                                          ('/language', Language),
                                          ('/regions', SetRegions),
                                          ('/setcredentials', SetCredentials),
                                          ('/deletecredentials', DeleteCredentials),
                                          ('/deleteallcredentials', DeleteAllCredentials),
                                          ('/selectdata', SelectData),
                                          ('/deletebucketkey', DeleteBucketKey),
                                          ('/deleteallbucketkeys', BuildDeleteAllKeysQuestion),
                                          ('/deleteallbucketkeyssure', DeleteAllBucketKeys),
                                          ('/fileupload', FileUploadHandler),
                                          ('/viewacl', ViewACL),
                                          ('/changeAcl', ChangeACL),
                                          ('/synchronize', SynchronizeStorages),
                                          ('/chooseraidlevel', RaidLevelConfig),
                                          ('/raidoneinfo', RaidOneInfo),
                                          ('/raidfiveinfo', RaidFiveInfo),
                                          ('/mergefile', MergeFile)
                                          ], debug=True)
    
    wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__':
    main()

